
$(function() {
	$("input[id^='code_s']:visible").autocomplete(Test.mold_code);
	
	$("input[id^='customer_s']:visible").autocomplete(Test.customer);

	$("input[id^='engineer_s']:visible").autocomplete(Test.emp);
	
	_ck_default("input[id^='engineer']:visible", "input[id^='engineer_t']:visible");

	Tip.emp('业务员');
	
	$("select[id^='emp_t_s']:visible").change(function() {
		var label = $("label[id^='label_emp_t']:visible");
		var a = $(this).val();
		if (a == 'emp') {
			label.html("业务员：");
		} else if (a == 'oper') {
			label.html("录入员：");
		}
	});
});

var Mold = {

	/**
	 * 景荣制造
	 */
	popup: function (e, p2, id, status) {
		$.cookie('id_', id);

		p2 = query(p2);
		$.cookie('p2', p2);

		var c2 = 'mold.php?do=Mold.view&id=' + id + p2;
		var c7 = 'mold.php?do=Plan.findPost&mold_s=' + id;
		var c8 = 'mold.php?do=Plan.report&id=' + id;

		var a2 = ['查看信息', 'url', 'Common.dialog_view_', '600x360', '查看信息'];
		var a7 = ['生产计划', 'url', 'list'];
		var a8 = ['产品生产', 'url', 'jswin', '1024x800'];
		
		if (status == 1) {
			var s = c2;

			return popup(e, [a2], s);
		}		

		var s = c2 + ", " + c7 + ", " + c8;

		return popup(e, [a2, a7, a8], s);
	},
	
	dialog_add_plan: function (url, title, xy) {
		var result = Common.result();
		$('#dialog_add').dialog('option', 'buttons', {
			"关闭": function() { 
				$(this).dialog("close");
			},
			
			"添加": function() {
				if (!confirm("确认是否提交？")) {
					return false;
				}

				var form = $("#form_add")[0];

				var body = {};
				body.id = form.id.value;
				body.piece = form.piece.value;
				body.technics = form.technics.value;
				body.emp = form.emp.value;
				body.content = form.content.value;

				body.t1 = form.t1.value;
				body.t2 = form.t2.value;

				body.hour = form.hour.value;
				body.minute = form.minute.value;

				$(this).dialog("close");
				
				var url = 'mold.php?do=Plan.addPost';

				$.post(url, body, function(data) {
					alert("添加成功！");
				});
			}
		});

		dialog_add(url, title, xy);
	}
};
